package com.ice.delay.task.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ice.delay.task.core.model.DelayTaskDetail;
import com.ice.delay.task.vo.req.DelayTaskDetailRetryVoReq;
import com.ice.delay.task.vo.req.DelayTaskDetailVoReq;
import com.ice.delay.task.vo.res.DelayTaskDetailVoRes;
import com.ice.framework.common.base.RPage;

import java.util.List;

/**
 * @author wangwei
 * @Date 2022/4/26 14:25
 */
public interface DelayTaskDetailService extends IService<DelayTaskDetail> {

    void saveDelayTask(DelayTaskDetail delayTaskDetail);

    Integer updateDelayTask(DelayTaskDetail delayTaskDetail);

    DelayTaskDetail findTaskDetail(String code);
    /**
     * 查询在nextTime时间内的任务
     * @param nextTime
     * @return
     */
    List<DelayTaskDetail> scheduleTaskQuery(long nextTime);

    /**
     * 查询执行中的任务（或者初始化中但已超时）
     * @return
     */
    List<DelayTaskDetail> runingTaskQuery();

    /**
     * 批量更新任务执行状态
     * @param code
     * @return
     */
    int batchUpdateExecuteStatus(List<String> code, Integer status);

    RPage<DelayTaskDetailVoRes> pageDetail(RPage<DelayTaskDetailVoReq> page);

    DelayTaskDetailVoRes findDetail(DelayTaskDetailVoReq req);

    void retry(DelayTaskDetailRetryVoReq req);
}
